package admin

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type homeController struct{}

func welcome(c *gin.Context) {
	// 使用加载的模板渲染并返回
	c.HTML(http.StatusOK, "welcome.html", gin.H{"title": "man website"})
}

func (Base homeController) Success(c *gin.Context, url string, message string) {
	c.JSON(http.StatusOK, gin.H{
		"status":      true,
		"msg":         message,
		"url":         url,
		"iframe_jump": false,
	})
}

func (Base homeController) Error(c *gin.Context, message string) {
	c.JSON(http.StatusOK, gin.H{
		"status": false,
		"msg":    message,
	})
}
func (Base homeController) Html(c *gin.Context, code int, name string, data gin.H) {

	if data == nil {
		data = gin.H{}
	}

	uid, _ := c.Get("uid")
	username, _ := c.Get("username")
	groupname, _ := c.Get("groupname")
	data["username"] = username
	data["uid"] = uid
	data["groupname"] = groupname

	c.HTML(code, name, data)
}
